{extend name="public/layerbase" /}
{block name="css"}

{/block}

{block name="content"}

    <div class="main-container" id="main-container">
        <div class="main-content">
            <div class="page-content">
                <div class="page-content-area">
                    <div class="row">
                        <div class="col-xs-12">
                            <div class="widget-box">
                                <div class="widget-header widget-header-blue widget-header-flat">
                                    <h4 class="widget-title lighter">新增用户</h4>
                                </div>
                                <div class="widget-body">
                                    <div class="widget-main">
                                        <div class="step-content pos-rel" >
                                            <div class="step-pane active" >

                                                <form class="form-horizontal " id="form" method="post">

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label no-padding-right" > <span style="color: red;">*</span> 用户名：</label>
                                                        <div class="col-sm-9">
                                                            <div class="clearfix">
                                                                <input type="text" name="username" placeholder="输入用户名" class="col-xs-12 col-sm-9" value=""/>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label no-padding-right" > <span style="color: red;">*</span> 手机：</label>
                                                        <div class="col-sm-9">
                                                            <div class="clearfix">
                                                                <input type="text" name="phone"  class="col-xs-12 col-sm-9" placeholder="输入手机" value="">
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label no-padding-right"> 密码：</label>
                                                        <div class="col-sm-9">
                                                            <div class="clearfix">
                                                                <input type="password" name="password"  class="col-xs-12 col-sm-9" placeholder="默认为121314" >
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label no-padding-right" > 确认密码：</label>
                                                        <div class="col-sm-9">
                                                            <div class="clearfix">
                                                                <input type="password" name="repassword" class="col-xs-12 col-sm-9" value="">
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label no-padding-right" > <span style="color: red;">*</span> 部门：</label>
                                                        <div class="col-sm-9">
                                                            <div class="clearfix" >
                                                                <select name="depar_id" class="col-sm-9">
                                                                    <option value="">请选择部门</option>
                                                                    {volist name="depars" id="vo"}
                                                                        <option value="{$vo.id}">{$vo._name}</option>
                                                                    {/volist}
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label no-padding-right" > <span style="color: red;">*</span> 职位：</label>
                                                        <div class="col-sm-9">
                                                            <div class="clearfix" >
                                                                <select name="position" class="col-sm-9">
                                                                    <option value="">请选择职位</option>
                                                                    {volist name="position" id="vo"}
                                                                    <option value="{$vo.id}">{$vo.title}</option>
                                                                    {/volist}
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label no-padding-right" > <span style="color: red;">*</span> 用户角色 ： </label>
                                                        <div class="col-sm-9">
                                                            <div class="clearfix" >
                                                                <select name="role_id[]" class="col-sm-9" id="role_id" multiple >
                                                                    {volist name="roles" id="vo"}
                                                                        <option value="{$vo.id}">{$vo.title}</option>
                                                                    {/volist}
                                                                </select>
                                                            </div>
                                                        </div>
                                                    </div>
                                                    <div class="form-group">
                                                        <label class="col-sm-3 control-label no-padding-right" > <span style="color: red;">*</span> 状态是否启用 ： </label>
                                                        <div class="col-sm-9">
                                                            <div class="clearfix" style="line-height: 32px;">
                                                                <input name="status" value="1" type="radio" checked/>启用&nbsp;&nbsp;&nbsp;&nbsp;
                                                                <input name="status" value="0" type="radio"  />禁用
                                                            </div>
                                                        </div>
                                                    </div>

                                                    <hr />
                                                    <div class="clearfix" style="text-align: center">
                                                        <div class="col-md-offset-3 col-md-9">
                                                            {:token()}
                                                            <button class="btn btn-info" type="submit" id="submit">
                                                                <i class="ace-icon fa fa-check bigger-110"></i>
                                                                提交
                                                            </button>

                                                            &nbsp; &nbsp; &nbsp;
                                                            <button class="btn" type="reset">
                                                                <i class="ace-icon fa fa-undo bigger-110"></i>
                                                                重置
                                                            </button>
                                                        </div>
                                                    </div>
                                                </form>

                                            </div>
                                        </div>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

{/block}

{block name="js"}
    {include file='base/select2'}

    <script>
        var define_fileds ={
            username: {
                message: '用户名验证失败',
                validators: {
                    notEmpty: {
                        message: '用户名不能为空'
                    },
                    stringLength:{
                        min: 2,
                        max: 5,
                        message: '用户名长度必须在2到5位之间'
                    },
                    different: {
                        field: 'password,repassword',
                        message: '密码和用户名不能相同'
                    }
                }
            },
            password: {
                validators: {
                    different: {
                        field: 'username',
                        message: '密码和用户名不能相同'
                    }
                }
            },
            repassword: {
                validators: {
                    identical: {
                        field: 'password',
                        message: '密码和确认密码不相同'
                    },
                    different: {
                        field: 'username',
                        message: '确认密码和用户名不能相同'
                    }
                }
            },
            phone: {
                validators: {
                    notEmpty: {
                        message: '手机号码不能为空'
                    },
                    regexp: {
                        regexp: /((^1[3|5|6|7|8|9]{1})+\d{9})$/,
                        message: '手机号码格式错误'
                    }
                }
            },
            depar_id: {
                validators: {
                    notEmpty: {
                        message: '部门不能为空'
                    }
                }
            },
            position: {
                validators: {
                    notEmpty: {
                        message: '职位不能为空'
                    }
                }
            },
            'role_id[]': {
                validators: {
                    notEmpty: {
                        message: '用户角色不能为空'
                    }
                }
            }

        };


        var ajaxurl = "{:url('add')}";

        $('#role_id').select2({
            placeholder : '请选择用户角色(可按住Ctrl键多选)',
            language: "zh-CN",
        });

    </script>


{/block}